/*
 * File:   monitorprocess.hpp
 * Author: lmz
 *
 * Created on September 5, 2015, 11:49 PM
 */

#ifndef MONITORPROCESS_HPP
#define	MONITORPROCESS_HPP
#include "datacollection.hpp"
#include "ftppool.hpp"
#include "occipool.hpp"
#include <vector>
#include <map>
#include "runtimeinfo.h"
#include "thread.hpp"
#include <WinBase.h>
#include "emailconfig.hpp"
#include "ftpprofiles.hpp"
#include "emailconfig.hpp"
#include "dbconfig.hpp"
#include "xmlparse.hpp"

using std::vector;
using std::map;
using namespace com_oocl_monitor::dao;
using namespace com_oocl_monitor::system;
using namespace com_oocl_monitor::domain;

namespace com_oocl_monitor {
	namespace controller {
		//impact whether profile will be process minutes
		const int INTERVAL = 30;
		//main thread sleep milliseconds
		const int HAVEAREST = 120000;

		const int MAXTHREADS = 10;
		class MonitorProcess {
		public:
			MonitorProcess(const string& dbConfigFile,const string& emailConfigFile,const string &profileconfigFile);
			void run();
			~MonitorProcess();
		private:
			void init();
			void loadDbConfig(const string& dbConfigFile);
			void loadEmailConfig(const string& emailConfigFile);
			void loadProfileConfig(const string& profileConfigFile);
			void perFtpHost(FtpProfile &ftpProfile);
		private:
			string _dbConfigFile;
			string _emailConfigFile;
			string _profileConfigFile;

			DbConfig _dbConfig;
			EmailConfig _emailConfig;
			FtpProfileList _ftpProfileList;

			RunTimeInfo *_runTimeInfo;
			XmlParse _xmlParse;
			HANDLE _sem;
			OcciPool *_dbpool;
			map<string,FtpPool*> _ftpPools;
		};
	}
}



#endif	/* MONITORPROCESS_HPP */

